package com.aigc.txt2img.controller.api;

import com.aigc.txt2img.config.NetEaseConfig;
import com.aigc.txt2img.third_party.net_ease.AiDraw;
import com.aigc.txt2img.third_party.net_ease.CreateImageParams;
import com.aigc.txt2img.utils.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/java_api/debug")
public class DebugController {

    @Autowired
    private NetEaseConfig netEaseConfig;

    /**
     * http://localhost:8080/api/debug/echo
     * @return
     */
    @GetMapping("/echo")
    public String echo() {
        return "debug Spring Boot!";
    }

    /**
     * http://localhost:8080/api/debug/json
     * @return
     */
    @GetMapping("/json")
    public ResponseUtil json()  throws Exception {

        CreateImageParams curlParams = new CreateImageParams();
        curlParams.setPrompt("夏天");
        curlParams.setStyleName("base");
        List<Integer> outputSize = new ArrayList<>();
        outputSize.add(512);
        outputSize.add(512);
        curlParams.setStyleName("base");
        curlParams.setOutputSize(outputSize);
        curlParams.setCallbackUrl("");
        AiDraw draw = new AiDraw();
        draw.CreateImage(curlParams);
        System.out.println(netEaseConfig);
        Map<Integer, String> colours = new HashMap<>();
        colours.put(1, "blue");
        colours.put(2, "yellow");
        colours.put(3, "green");
        return ResponseUtil.success(colours);
    }

    /**
     * http://localhost:8080/api/debug/exp
     * @return
     */
    @GetMapping("/exp")
    public ResponseUtil exp() {

        System.out.println(1/0);
        Map<Integer, String> colours = new HashMap<>();
        colours.put(1, "blue");
        colours.put(2, "yellow");
        colours.put(3, "green");
        return ResponseUtil.success(colours);
    }


}